package sojo.com.inverter.service.Impl.device;

import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import sojo.com.inverter.entity.InverterVo;
import sojo.com.inverter.modbus.ModbusClient;
import sojo.com.inverter.service.Device;
import sojo.com.inverter.service.ScheduledTaskService;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author cheng_hu
 * @description:
 * @date 2023-02-22 15:33:33
 */
@Slf4j
@Component
@Scope(value = "singleton")
public class DeviceHuaweiInverter_01 implements Device {


    private final static String taskKey = "huaweiInverter_01";

    private final ConcurrentHashMap<String, String> alarmDic = new ConcurrentHashMap<>();

//    @Qualifier("modbusTCPHuaweiInverter_01")
    @Autowired
    private ModbusClient modbusClient;

    @Autowired
    private ScheduledTaskService scheduledTaskService;


    @PostConstruct
    public void init() {
//        scheduledTaskService.startTask(taskKey, modbusClient, this);
    }

    @PreDestroy
    public void destroy() {
//        scheduledTaskService.stopTask(taskKey);
    }

    @Override
    public void analysisData(InverterVo inverterVo) {


        log.info("接收返回数据" + JSONUtil.toJsonStr(inverterVo));
    }
}
